
package ejerciciostrategy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;


public class EjercicioStrategy {

  
    public static void main(String[] args) {
        JOptionPane.showMessageDialog(null, "bienbenido al pratron de diseño strategy");
        NameList lista=new NameList(new SortAscendente());
        for (int i=0; i<5;i++){
            System.out.println("nombre"+(i+1));
            String nombre = leerNombre();
            lista.addName(nombre);
        }
        System.out.println ("*****ascendente******");
        lista.printList();
        System.out.println ("*****descendente*****");
        lista.printList(new SortDescendente());
        System.out.println ("*****random*****");
        lista.printList(new SortRandom());
    }
    
    
    
    private static String leerNombre(){
        
       BufferedReader reader= new BufferedReader (new InputStreamReader(System.in));
       
       String s=null;
       try{
           s = reader.readLine();
       } catch (IOException ex){
           ex.printStackTrace();
       }
       return s;
    }
}
